import java.sql.*;


public class update {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.cj.jdbc.Driver");
        String url = "jdbc:mysql://127.0.0.1:3306/db4?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false&allowPublicKeyRetrieval=true";
        //数据库账号
        String user="root";
        //数据库密码
        String password="cnj147759399";
        Connection conn = DriverManager.getConnection(url, user, password);
        Statement st = conn.createStatement();
        String sql ="UPDATE cat SET `名字`='yi' WHERE ID=1";
        int i = st.executeUpdate(sql);
        if (i>0){
            System.out.println("更新成功！");
        }
        st.close();
        conn.close();
    }
}